package com.mars.diancan.utils;

import com.mars.diancan.common.CodeEnum;

/**
 * 枚举工具类
 * each的属性：
 *    - code
 *    - msg
 *    - name
 * @author MARS
 * @date 2018/7/4
 */
public class EnumUtil {

    public static <T extends CodeEnum>T getByCode(Integer code, Class<T> enumClass){
        // 遍历
        for (T each : enumClass.getEnumConstants()) {
            if (code.equals(each.getCode())) {
                return each;
            }
        }
        return null;
    }
}
